<template>
	<view>
		<view class="header" v-cloak>
			累计分红： +{{restop}}元
		</view>
		<!-- 订单列表 -->
		<view class="load-more">
			<view class="container">
				<!-- 带上拉加载的数据列表 -->
				<view class="big-loading-text loading-text ">
					<text>期数</text>
					<text>分红金额(元)</text>
					<text>管理费</text>
					<text>分红时间</text>
				</view>
				<view v-for="(item,key) in res" :key="key" class="loading-text">
					<text v-cloak>{{item.qishu}}</text>
					<text v-cloak>{{item.shiji_price}}</text>
					<text v-cloak>{{item.glfee}}</text>
					<text v-cloak>{{item.time}}</text>
				</view>
			</view>
			<uni-load-more v-if="load == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from '../../../../components/uni-load-more.vue';
	var _self,
	page = 1,
	timer = null;
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				restop:0,
				openid:'',
				active:"active",
				systemInfo:[],
				index:1,
				res:[],
				loadingType:0,
				loadingText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多订单了"
				},
				load: 0
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
					this.setAjaxList()
				},
				fail: () => {
					uni.navigateTo({
						url: '../member'
					});
				}
			});
		},
		// 上拉加载
		onReachBottom(){
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=commission.order.get_aticheng&app=1&page='+this.index,
				success: res => {
					// console.log(res.data.result.list)
					if(res.data.result.list.length == 0){
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1;
				},
				fail: () => {},
				complete: () => {}
			});
			
		},
		methods:{
			setAjax(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.share&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						this.restop = res.data.leiji_price
					},
					fail: () => {},
					complete: () => {}
				});
			},
			// 订单奖金管理极差时间/列表
			setAjaxList(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=commission.order.get_share&app=1&page=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.res = res.data.result.list
						// console.log(this.res)
						// 大于50个数据时
						if(res.data.result.total > res.data.result.pagesize){
							this.load = 1
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jumpcoin(e){
				var id =e.currentTarget.dataset.id
				uni.navigateTo({
					url: 'mingxi?id='+ id
				});
			},
			jump(e){
				var src =e.currentTarget.dataset.src
				uni.navigateTo({
					url: src
				});
			}
		}
	}
</script>

<style>
.header {
	background-color: #fea23d;
	color: #fff;
	font-weight: 500;
	text-align: center;
	padding: 22upx;
}
.container {
	background-color: #FEA23D;
}
.loading-text {
	background-color: fff;
	display: flex;
}

.loading-text text:nth-child(1) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 1;
	text-align: center;
	font-size: 25upx;
}
.loading-text text:nth-child(2) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 2;
	text-align: center;
	font-size: 25upx;
}
.loading-text text:nth-child(3) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 1;
	text-align: center;
	font-size: 25upx;
}
.loading-text text:nth-child(4) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 2;
	text-align: center;
	font-size: 25upx;
}
.all_add {
	height: 80upx;
	text-align: center;
	line-height: 80upx;
	background-color: rgb(254,162,61);
	color: #fff;
}
.big-loading-text {
	font-weight: 550;
	border-bottom: 2upx solid rgb(243,243,243);
}
uni-page-body{height:100%;}
</style>

